<template>
    <div>
      <h1>axios二次封装</h1>
      <div v-show="flag" class="alert alert-danger" role="alert">
        {{ message }}
      </div>
      <button @click="handler">点击</button>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue';
  import { getTopicsByParams } from './axios';
  
  const flag = ref(false);
  const message = ref('');
  
  const handler = e => {
    flag.value = false;
    message.value = '';
  
    getTopicsByParams({limit:5, page:2, tab: 'ask'})
    .then( res=> {
      console.log('res=>', res);
    } ).catch( err=> {
      flag.value = true;
      message.value = err.message;
      console.log('UI 界面捕获错误 err=>', err);
    } )
  }
  
  
  
  
  </script>
  
  <style lang="scss" scoped>
  
  </style>